import { useFormContext } from "./contexts";
import { Dynamic } from "solid-js/web";
import type { FormSubmitProps } from "./types";

export const FormSubmit = (props: FormSubmitProps) => {
  const form = useFormContext();

  return (
    <Dynamic
      component="button"
      type="button"
      {...props}
      onClick={() => form?.submit()}
    />
  );
};

export const FormReset = (props: FormSubmitProps) => {
  const form = useFormContext();

  return (
    <Dynamic
      component="button"
      type="button"
      {...props}
      onClick={() => form?.reset()}
    />
  );
};
